package com.ece.pfe_rover_pvt_ines_ece_application.model;

import java.util.Date;
import java.util.UUID;

import com.parse.ParseClassName;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseQueryAdapter;
import com.parse.ParseUser;

/**
 * Parse objects class for Measurements  
 * @author mathieubakrim
 *
 */
@ParseClassName("Measurements")
public class Measurements extends ParseObject {

	//Entry unique id number
	public int getEntryId() {return getInt("EntryId");}
	public void setEntryId(int entryId) {put("EntryId", entryId);}
	
	//Identifier  input (pannel 1 or 2)
	public int getInputId() {return getInt("IdPan");}
	public void setInputId(int IdPan) {put("IdPan", IdPan);}
	
	// Intensity
	public double getI() {return getDouble("I");}
	public void setI(Double I) {put("I", I);}

	// Tension	
	public double getV() {return getDouble("V");}
	public void setV(Double V) {put("V", V);}
	
	//Luminosity
	public double getLum() {return getDouble("Lum");}
	public void setLum(Double Lum) {put("Lum", Lum);}
	
	//Pannel temperature
	public double getTpan() {return getDouble("Tpan");}
	public void setTpan(Double Tpan) {put("Tpan", Tpan);}	
	
	//Ambient air temperature input
	public double getTair() {return getDouble("Tair");}
	public void setTair(Double Tair) {put("Tair", Tair);}
	
	//Wind speed input
	public double getSwind() {return getDouble("Swind");}
	public void setSwind(Double Swind) {put("Swind", Swind);}
	
	//Puissance
	public double getP(){return getDouble("P");}
	public void setP(Double P){put("P", P);}
	
	//GPS input
	public String getGPS() {return getString("GPS");}
	public void setGPS(String string) {put("GPS", string);}
		
	// TimeStamp
	public long getDate(){return getLong("Date");}
	public void setDate(Long date){put("Date", date);}
		
	public ParseUser getAuthor() {return getParseUser("author");}
	public void setAuthor(ParseUser currentUser) {put("author", currentUser);}
	
	public boolean isDraft() {return getBoolean("isDraft");}
	public void setDraft(boolean isDraft) {put("isDraft", isDraft);}
	
	public void setUuidString() {UUID uuid = UUID.randomUUID();put("uuid", uuid.toString());}
	public String getUuidString() {return getString("uuid");}
	
	public static ParseQuery<Measurements> getQuery() {return ParseQuery.getQuery(Measurements.class);}
	
	public void getAllMeasurements(){
		// Set up the Parse query to use in the adapter
		@SuppressWarnings("unused")
		ParseQueryAdapter.QueryFactory<Measurements> factory = new ParseQueryAdapter.QueryFactory<Measurements>() {
				public ParseQuery<Measurements> create() {
						ParseQuery<Measurements> query = Measurements.getQuery();
						query.orderByDescending("createdAt");
						query.fromLocalDatastore();
						return query;
					}
		};
	}
}
